package com.hongyang.vo;

//数据统一响应
public class ResultVO<T> {
    //响应编号
    private int code;
    //响应消息
    private String message;

    //携带的值
    private T data;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    //成功(新增，修改以及其它)
    public static  ResultVO success(String message){
        ResultVO<String> vo=new ResultVO<>();
        vo.setCode(ResultEnum.SUCDESS.getCode());
        vo.setMessage(ResultEnum.SUCDESS.getMessage());
        vo.setMessage(message);
        return vo;
    }

    //成功(传值)
    public static <T> ResultVO  success(T data){
        ResultVO  vo=new ResultVO();
        vo.setCode(ResultEnum.SUCDESS.getCode());
        vo.setMessage(ResultEnum.SUCDESS.getMessage());
        vo.setData(data);
        return vo;
    }

    //失败
    public static  ResultVO failed( ResultEnum  resultEnum){
        ResultVO<String>  vo=new ResultVO<String>();
        vo.setCode(resultEnum.getCode());
        vo.setMessage(resultEnum.getMessage());
        return vo;
    }

}
